package com.sanchunhui.psc.presenter

import com.sanchunhui.psc.data.protocol.ResponseInfo
import com.sanchunhui.psc.ext.excute
import com.sanchunhui.psc.presenter.view.AddTeamView
import com.sanchunhui.psc.presenter.view.DeviceView
import com.sanchunhui.psc.rx.BaseSubscriber
import com.sanchunhui.psc.service.DeviceService
import com.sanchunhui.psc.service.ProjectTeamService
import javax.inject.Inject

/**
 * @Author zyx
 * @Date 2021/7/13-12:41
 * @Dscribe
 */
class AddDevicePresenter @Inject constructor() : BasePresenter<DeviceView>() {

    @Inject
    lateinit var service: DeviceService

    /*
        为⽤户增加设备
     */
    fun addDeviceForMember( token: String,
                            mac: String,
                            device_type_id: Int,
                            name: String) {
        if (!checkNetWork()) {
            return
        }
        mView.showLoading()
        service.addDeviceForMember(token,
            mac,
            device_type_id,
            name).excute(object : BaseSubscriber<ResponseInfo>(mView) {
            override fun onNext(t: ResponseInfo) {
                mView.onMemberAddDeviceResult(t)
            }
        }, lifecycleProvider)

    }
}